package matlap.server;

import java.sql.Connection;
import java.util.List;

import matlap.client.services.school.SchoolService;
import matlap.database.ConnectionManager;
import matlap.database.dao.DAOFactory;
import matlap.database.dao.SchoolDAO;
import matlap.shared.School;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */

public class SchoolServiceImpl extends RemoteServiceServlet implements
		SchoolService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7486383120819236929L;
	Connection con = null;
	ConnectionManager conman = null;
	DAOFactory df = DAOFactory.getInstance();
	SchoolDAO sd = df.getSchoolDAO();

	/**
	 * Turns back the schools number from the school table.
	 */

	public int getSchoolsNumber() {
		return sd.getSchoolsNumber();
	}

	/**
	 * Turns back the schools from the school table in a School list.
	 */

	public List<School> getSchools() {
		return sd.getSchools();
	}

	/**
	 * Turns back all of the schools name from the school table in School list.
	 */

	public List<School> selectSchoolsName() {
		return sd.selectSchoolsName();
	}

	public List<String> selectSchoolsNameByLocality(String localityName) {
		return sd.selectSchoolsNameByLocality(localityName);
	}

	/**
	 * Turns back the schools locality from the school table and the locality
	 * table in a School list.
	 */

	public List<School> selectSchoolsLocality() {
		return sd.selectSchoolsLocality();

	}

	/**
	 * Turns back the schools from the school table in a School list by adding
	 * schools name and locality.
	 */

	public List<School> getSchoolsBy(String schoolName, String localityName) {
		return sd.getSchoolsBy(schoolName, localityName);
	}

	/**
	 * Turns back the schoolsID from the school table by adding schools name.
	 */

	public int getSchoolId(String schoolName) {
		return sd.getSchoolId(schoolName);
	}

	/**
	 * Inserts schools into the school table by adding schools name and
	 * locality.
	 */

	public void insertSchool(String schoolName, String localityName) {
		sd.insertSchool(schoolName, localityName);
	}

	/**
	 * Turns back the localityID from the locality table by adding locality
	 * name.
	 */

	public int getLocalityId(String localityName) {
		return sd.getLocalityId(localityName);
	}

	public List<String> selectLocality() {
		return sd.selectLocality();
	}

}
